package com.zz.common.base.dto;

import com.zz.common.base.enums.BaseExceptionEnum;

import java.io.Serializable;

/**
 * @author zl
 * @version 1.0
 */
public class ResponseDTO<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private String code;
    private String message;
    private T data = null;

    public ResponseDTO() {
        this.code = "01";
        this.message = "success";
    }

    public ResponseDTO(BaseExceptionEnum baseExceptionEnum, T data) {
        this.code = baseExceptionEnum.getCode();
        this.message = baseExceptionEnum.getMessage();
        this.data = data;
    }

    public ResponseDTO(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResponseDTO(T data) {
        this.code = "01";
        this.message = "success";
        this.data = data;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public void setCode(BaseExceptionEnum baseExceptionEnum) {
        this.code = baseExceptionEnum.getCode();
        this.message = baseExceptionEnum.getMessage();
    }
}
